<template>
  <el-dialog :visible.sync="visible" :close-on-click-modal="false">
    <el-form ref="dataForm" :model="dataForm" label-position="right" label-width="80px" style="width: 500px; margin-left:50px;">
        <el-form-item label="策略名称" prop="portfolioName">
          <el-input v-model="dataForm.portfolioName" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="visible=false">取消</el-button>
        <el-button type="primary" @click="addSubmit()">提交</el-button>
      </div>
  </el-dialog>
</template>

<script>
import { updateStrategyPortfolioById } from '@/api/combination'

export default {
  data() {
    return {
      visible: false,
      dataForm: {
        portfolioId: '',
        portfolioName: ''
      }
    }
  },
  methods: {
    init(row) {
      this.visible = true
      this.$nextTick(() => {
        this.$refs['dataForm'].resetFields()
        if(row) {
          this.dataForm.portfolioName = row.portfolioName
          this.dataForm.portfolioId = row.portfolioId
        }
      })
    },
    addSubmit() {
      updateStrategyPortfolioById({
        ...this.dataForm
      }).then(res => {
        if(res.code == 0) {
          this.$notify({
            type: 'success',
            message: '修改成功',
            duration: 2000
          })
          this.visible = false
          this.$emit('closeOpen')
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
